package com.joshua.spring.spi;

import com.joshua.spring.entity.vo.GlobalResponse;
import com.joshua.spring.fallback.ProviderDemoClientFallback;
import com.joshua.spring.form.ContainsArrayObjForm;
import com.joshua.spring.form.ParamsObjFrom;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import static com.joshua.spring.constant.ProviderApiConstants.*;
import static com.joshua.spring.constant.ProviderApiConstants.Demo.*;

/**
 * description
 * package com.spring.joshua.spi
 * classname  ProviderDemoClient
 *
 * @author <a href="mailto:joshualwork@163.com">joshua_liu</a>
 * @date 2020/3/30 16:44
 */
@FeignClient(name = APPLICATION_CODE,
        path = CONTEXT_PATH + PROVIDER,
        configuration = {FeignAutoConfiguration.class}, fallback = ProviderDemoClientFallback.class)
public interface ProviderDemoClient {
    String PATH_ID = Demo.PATH_ID;

    /**
     * description:
     *
     * @param form
     * @return {@link GlobalResponse}
     * @author <a href="mailto:joshualwork@163.com">joshua_liu</a>
     * @date 2020/3/30 19:06
     */
    @GetMapping(consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    GlobalResponse paramsObj(@SpringQueryMap ParamsObjFrom form);

    /**
     * description:
     *
     * @param id
     * @return {@link GlobalResponse}
     * @throws
     * @author <a href="mailto:joshualwork@163.com">joshua_liu</a>
     * @date 2020/3/30 19:06
     */
    @GetMapping(PATH_ID)
    GlobalResponse pathInfo(@PathVariable(name = "id") String id);

    /**
     * description:
     *
     * @param ids
     * @return {@link GlobalResponse}
     * @throws
     * @author <a href="mailto:joshualwork@163.com">joshua_liu</a>
     * @date 2020/3/30 19:06
     */
    @GetMapping(value = ID_ARRAY)
    GlobalResponse arrayInfo(@RequestParam("ids") String[] ids);

    /**
     * description:
     *
     * @param form
     * @return {@link GlobalResponse}
     * @throws
     * @author <a href="mailto:joshualwork@163.com">joshua_liu</a>
     * @date 2020/3/30 19:06
     */
    @GetMapping(value = QUERY_LIST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    GlobalResponse listInfo(@SpringQueryMap ContainsArrayObjForm form);
}
